<template>
  <div v-if="$store.state.userinfo" class="home-content">
    <!-- admin -->
    <home-admin v-if="permissionType === 2"></home-admin>
    <!-- 多单位 -->
    <home-multiple v-else-if="permissionType === 1 && isMuilUnitUser" ref="homeMultiple"></home-multiple>
    <!-- 单单位 -->
    <home-singlle-unit v-else ref="homeSingle"></home-singlle-unit>
  </div>
</template>

<script>
import homeAdmin from './pageModel/HomeAdmin'
import homeMultiple from './pageModel/HomeMultiple'
import homeSinglleUnit from './homePageModel/HomeSinglleUnit'

export default {
  name: 'Index',
  components: {
    homeAdmin,
    homeMultiple,
    homeSinglleUnit
  },
  data () {
    return {
      permissionType:'',//2是超级管理员
      isMuilUnitUser:'',//1是监管方、多单位用户
      msg: '看板',
    }
  },
  created () {
    if(this.$store.state.userinfo){
      this.permissionType = this.$store.state.userinfo.permissionType
      this.isMuilUnitUser = this.$store.state.userinfo.isMuilUnitUser
      this.$nextTick(() => {
        if(this.permissionType === 2) {
          window.ILINKHOMEWS = null
        } else if(this.permissionType === 1 && this.isMuilUnitUser) {
          window.ILINKHOMEWS = this.$refs['homeMultiple'].dealWithMultipleWSData
        } else {
          window.ILINKHOMEWS = this.$refs['homeSingle'].dealWithSingleWSData
        }
      })
    }
    
  },
}
</script>

<!-- Add 'scoped' attribute to limit CSS to this component only -->
<style>
  .home-content{
    height: 100%;
    width: 100%;
  }
</style>
